Skip to content

fix: use await asyncio.sleep instead of blocking time.sleep in async voter retry#6243

Open
kratos0718 wants to merge 1 commit into
jina-ai:masterfrom
kratos0718:fix/async-blocking-sleep-voter
Open

fix: use await asyncio.sleep instead of blocking time.sleep in async voter retry#6243
kratos0718 wants to merge 1 commit into
jina-ai:masterfrom
kratos0718:fix/async-blocking-sleep-voter

Conversation

@kratos0718

Copy link
Copy Markdown

Summary

In jina/orchestrate/deployments/__init__.py, the voter-add retry loop runs inside an async function (it awaits async_call_add_voter), but its back-off uses a blocking time.sleep(2.0):

success = await async_call_add_voter(leader, str(replica_id), voter_address)
if success:
    break
else:
    time.sleep(2.0)   # blocks the event loop

time.sleep blocks the entire event loop for its duration — 2s per retry, up to ~10s across the 5 attempts. While it sleeps, every other coroutine on the loop is frozen.

Fix

Use await asyncio.sleep(2.0), which backs off without blocking the loop. asyncio is already imported; behavior is otherwise identical.

  • Compiles cleanly (python -m py_compile).

…voter retry

The retry loop in _async_call_add_voters awaits async_call_add_voter but
backs off with a blocking time.sleep(2.0), freezing the event loop for 2s
per retry (up to ~10s across 5 attempts). Use await asyncio.sleep so the
loop stays free. The sync sibling _call_add_voters is left unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant